package com.shuaiche.yeguan.views.brandselectbar.third;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.shuaiche.yeguan.R;
import com.shuaiche.yeguan.views.brandselectbar.ItemBean;

import java.util.ArrayList;
import java.util.List;

import androidx.recyclerview.widget.RecyclerView;

/**
 * Created by baoyinbo on 2017/12/5.
 */

public class SCThirdRightSelectViewAdapter extends RecyclerView.Adapter<SCThirdRightSelectViewAdapter.ViewHolder> {
    private LayoutInflater mInflater;
    private Context mContext;
    private List<ItemBean> mLists = new ArrayList<>();

    public SCThirdRightSelectViewAdapter(Context mContext, List<ItemBean> mDatas) {
        this.mContext = mContext;
        this.mLists = mDatas;
        mInflater = LayoutInflater.from(mContext);
    }
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(mInflater.inflate(R.layout.sc_item_brand_second_list, parent, false));
    }

    @Override
    public void onBindViewHolder(final ViewHolder holder, final int position) {
        holder.title.setText(mLists.get(position).getName());
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callListener.itemClick(position);
            }
        });
    }

    @Override
    public int getItemCount() {
        return mLists.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        TextView title;

        public ViewHolder(View itemView) {
            super(itemView);
            title = (TextView) itemView.findViewById(R.id.tvTitle);
        }
    }

    public interface CallbackListener{
        void itemClick(int position);
    }

    /**回调 拨打电话 / 隐藏 监听*/
    public CallbackListener callListener;

    public void setCallbackListener (CallbackListener callListener) {
        this.callListener = callListener;
    }
}
